# -*- coding: utf-8 -*-#
#-------------------------------------------------------------------------------
# 建立者:        潘炎珍  
# Name:         demo03
# Description:
# Author:       98745
# Date:         2019/3/12
#-------------------------------------------------------------------------------

from urllib3 import *
import re
disable_warnings()
http=PoolManager()
url = 'https://list.tmall.com/search_product.htm?spm=a220m.1000858.1000724.4.53ec3e72bTyQhM&q=%D0%D8%D5%D6&sort=d&style=g&from=mallfp..pc_1_searchbutton#J_Filter'
def str2Headers(file):
    hd={}
    f=open(file,'r')
    ht=f.read()
    headers=re.split('\n',ht)
    for header in headers:
        r=re.split(':',header,maxsplit=1)
        hd[r[0]]=r[1]
    f.close()
    return hd
headers=str2Headers('headers.txt')
response=http.request('GET',url,headers=headers)
data=response.data.decode('GB18030')
print(data)